package mortal.game.control
{
    import Message.Public.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.model.*;
    import mortal.game.mvc.*;
    import mortal.game.view.guildFlame.*;
    import mortal.game.view.shortcuts.item.*;
    import mortal.mvc.core.*;

    public class GuildFlameController extends Controller
    {

        public function GuildFlameController()
        {
            
        }

        override protected function initServer() : void
        {
            NetDispatcher.addCmdListener(ServerCommand.GuildFlameOpen, this.onGuildFlameOpen);
            NetDispatcher.addCmdListener(ServerCommand.GuildFlameClose, this.onGuildFlameClose);
            NetDispatcher.addCmdListener(ServerCommand.GuildFlameBig, this.onGuildFlameBig);
            NetDispatcher.addCmdListener(ServerCommand.GuildFlameShort, this.onGuildFlameShort);
            Dispatcher.addEventListener(EventName.GuildQuickBackFlame, this.onQuickBackFlame);
            Dispatcher.addEventListener(EventName.GuildFlameAddFireWood, this.onAddFireWood);
            
        }

        private function onGuildFlameOpen(param1:SGuildFlameOpen) : void
        {
            FlameIconView.instance.show();
            FlameIconView.instance.startCountdown(param1.endDt);
            
        }

        private function onGuildFlameClose(param1:Object) : void
        {
            FlameIconView.instance.hide();
            
        }

        private function onGuildFlameBig(param1:Object) : void
        {
            var _loc_2:* = new TaskShowTargetInfo();
            _loc_2.showStr = "仙盟圣火似乎更旺盛了些。";
            _loc_2.showTime = 5;
            MsgManager.showTaskTarget(_loc_2);
            
        }

        private function onGuildFlameShort(param1:Object) : void
        {
            var _loc_2:* = new TaskShowTargetInfo();
            _loc_2.showStr = "仙盟圣火似乎变弱了一些。";
            _loc_2.showTime = 5;
            MsgManager.showTaskTarget(_loc_2);
            
        }

        private function onQuickBackFlame(event:DataEvent) : void
        {
            if (cache.guild.myGuildInfo)
            {
                GameProxy.copy.enterGuild_async(cache.guild.myGuildInfo.guildId, false);
            }
            
        }

        private function onAddFireWood(event:DataEvent) : void
        {
            var _loc_2:* = cache.pack.backPackCache.getItemsByJudge(ItemsUtil.isFireWood);
            if (_loc_2.length > 0)
            {
                GameProxy.guildProxy.addFireWood(1);
            }
            else
            {
                MsgManager.addBroadCast("你的包裹里面没有柴火!");
            }
            
        }

    }
}
